﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace todo.export
{
    public partial class ExportForm : Form
    {
        public PlainTextExportSettings Settings;

        public ExportForm()
        {
            InitializeComponent();
            this.Font = SystemFonts.MessageBoxFont;
        }

        private void btnExport_Click(object sender, EventArgs e)
        {
            var settings = this.Settings;
            settings.ExcludeDoneItems = optUndoneItems.Checked;
            int indentCount;
            if (int.TryParse(txtIndentCount.Text, out indentCount))
            {
                settings.IndentCount = indentCount;
            }
            settings.IndentType = cbIndentType.SelectedIndex;
            settings.WithCheckmark = chkPrependCheckmark.Checked;

            DialogResult = DialogResult.OK;
        }

        private void ExportForm_Load(object sender, EventArgs e)
        {
            cbIndentType.SelectedIndex = 0;
            Localize();
        }

        private void Localize()
        {
#if zh
            this.grpTodos.Text = "待办项";
            this.grpFormatting.Text = "格式";
            this.lblIndent.Text = "缩进";
            this.btnExport.Text = "导出";
            this.btnCancel.Text = "取消";
            this.optAllItems.Text = "所有待办项";
            this.optUndoneItems.Text = "未完成待办项";
            this.chkPrependCheckmark.Text = "在已完成项前加上打勾符号";
            this.cbIndentType.Items[0] = "空格";
            this.cbIndentType.Items[1] = "制表符";
#endif
        }

        private void optAllItems_CheckedChanged(object sender, EventArgs e)
        {
            chkPrependCheckmark.Enabled = true;
        }

        private void optUndoneItems_CheckedChanged(object sender, EventArgs e)
        {
            chkPrependCheckmark.Enabled = false;
        }
    }
}